home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
cmln1286.arc
/
BNCHMARK.ADA
/
HANOI.ADA
< prev
next >
Wrap
Text File
|
1986-10-21
|
1KB
|
43 lines
--with TEXT_IO; use TEXT_IO;
procedure HANOI is
--
-- Towers of Hanoi problem
-- Author: Bruce A. Bergman
-- Source available from Mark Petersen's Alpo-Net FIDO board at
-- (619) 741-3412, 300/1200/2400 8,N,1
--
------------------------------
-- declarations
------------------------------
number_of_disks : constant natural := 10;
-- peg : constant array (1..3) of string (1..3) := (" A ", " B ", " C ");
------------------------------
-- MOVE_DISK
------------------------------
procedure MOVE_DISK(source, temp, destin : in natural;
how_many : in natural) is
begin
if how_many > 1 then
move_disk(source, destin, temp, how_many-1);
end if;
-- put_line("Moving disk from" & peg(source) & "to" & peg(destin));
if how_many > 1 then
move_disk(temp, source, destin, how_many-1);
end if;
end MOVE_DISK;
begin
move_disk(1, 2, 3, number_of_disks);
end HANOI;